import { ApiProperty } from "@nestjs/swagger";
import { IsNotEmpty, IsNumber, IsString } from "class-validator";
import { CourseEnum } from "src/enums/school/course.enum";
import { WeekEnum } from "src/enums/school/week.enum";

export class DetailDto {
  @ApiProperty({ title: "第几节课", example: 1 })
  index: number;

  @ApiProperty({ title: "课程", example: CourseEnum.Math, enum: CourseEnum })
  course: `${CourseEnum}`;

  @ApiProperty({ title: "星期", example: WeekEnum.monday, enum: WeekEnum })
  week: keyof typeof WeekEnum;
}

export class CreateCourseDto {
  @ApiProperty({ title: "班级Id", required: true })
  @IsNotEmpty({ message: "班级Id不能为空" })
  @IsNumber()
  classId: number;

  @ApiProperty({ title: "年份和周数", required: true })
  @IsNotEmpty({ message: "年份和周数不能为空" })
  @IsString()
  yearWeek: string;

  @ApiProperty({ title: "课程表详细数据", type: [DetailDto], isArray: true, required: true })
  @IsNotEmpty({ message: "课程表详细数据不能为空", each: true })
  details: { index: number; course: `${CourseEnum}`; week: keyof typeof WeekEnum }[];
}
